<?php 
include("../../global.php");
include("../global_css.php");
$ac=$_REQUEST["ac"];
$appid=$_REQUEST["appid"];
switch($ac){
	case "modifysave":
		$db->query("update app set name='".$_POST["name"]."',width='".$_POST["width"]."',height='".$_POST["height"]."' where appid='$appid'");
		msg_print("操作成功","index.php?ac=modify&appid=$appid");
		break;
}
?>
<div class="row-fluid sortable">
<?php 
if($ac=='modify'){
$result=$db->fetchAll("select * from app where appid='$appid'");
$row=$result[0];
?>
	<div class="box span12">
		<div class="box-header well" data-original-title>
			<h2><i class="icon-edit"></i>&nbsp; 编辑</h2>
		</div>
		<div class="box-content">
			<form action="?ac=modifysave" method="post" class="form-horizontal">
			<input type="hidden" name="appid" value="<?=$appid?>">
				<fieldset>
				<div class="control-group">
					<label class="control-label" for="appendedInputButton">应用图标：</label>
					<div class="controls">
					  <div class="input-append">
						<input id="appendedInputButton" size="16" type="text" value="<?=$row["icon"]?>"><button class="btn" type="button">Go!</button>
					  </div>
					</div>
				  </div>
				  <div class="control-group">
					<label class="control-label" for="prependedInput">应用名称：</label>
					<div class="controls">
					  <div class="input-prepend">
						<input id="prependedInput" size="16" type="text" name="name" value="<?=$row["name"]?>">
					  </div>
					  
					</div>
				  </div>
				  
				  <div class="control-group">
					<label class="control-label" for="appendedPrependedInput">窗口大小：</label>
					<div class="controls">
					  <div class="input-prepend input-append">
						<span class="add-on">宽</span><input id="appendedPrependedInput" name="width" size="16" type="text"  style="width:30px;" value="<?=$row["width"]?>"><span class="add-on">px</span>&nbsp;
						<span class="add-on">宽</span><input id="appendedPrependedInput" name="height" size="16" type="text"  style="width:30px;" value="<?=$row["height"]?>"><span class="add-on">px</span>
					  </div>
					</div>
				  </div>

				  <div class="form-actions">
					<input type="submit" class="btn btn-primary" value="保存">
					<input type="reset" class="btn" value="取消">
				  </div>
				</fieldset>
			</form>
		</div>
	</div>
<?php 
}else{
$result=$db->fetchAll("select * from app");
?>
	<div class="box span12">
	<div class="box-header well" data-original-title>
		<h2><i class="icon-user"></i> 应用列表</h2>
	</div>
	<div class="box-content">
		<table class="table table-striped table-bordered bootstrap-datatable datatable">
		  <thead>
			  <tr>
				  <th>应用名称</th>
				  <th>类型</th>
				  <th>窗口大小</th>
				  <th>分类</th>
				  <th>操作</th>
			  </tr>
		  </thead>   
		  <tbody>
		  <?php if(is_array($result)){
		 			foreach($result as $rs){ 
		  ?>
			<tr>
				<td><?=$rs["name"]?></td>
				<td class="center"><?=$rs["type"]?></td>
				<td class="center">大小：<?=$rs["width"]?> * <?=$rs["height"]?></td>
				<td class="center">
					<span class="label label-success"><?=$rs["type"]?></span>								</td>
				<td class="center">
					<a class="btn btn-info" href="#">
						<i class="icon-edit icon-white"></i>  
						Edit									</a>
					<a class="btn btn-danger" href="#">
						<i class="icon-trash icon-white"></i> 
						Delete									</a>								</td>
			</tr>
		  <?php }} ?>
		  </tbody>
	  </table>            
	</div>
	</div>	
<?php } ?>	
</div>